var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')

module.exports = {
	entry: {
		bootstrap: './index',
		lib: [ 'jquery' ]
	},
	output: {
		path: __dirname + '/dist',
  	filename: 'index.js'
	},
	module: {
		rules: [
			{
				test: /\.css$/,
				use: ['style-loader', 'css-loader']
			},
			{
				test: /\.(eot|woff2|woff|ttf|svg)$/,
				use: 'url-loader'
			},
			{
				test: /\.less$/,
				use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: ['css-loader', 'less-loader'] })
			}
		]
	},
	plugins: [
		new webpack.optimize.CommonsChunkPlugin({
    	name: 'lib',
    	filename: 'lib.min.js'
    }),
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery"
    }),
		new webpack.HotModuleReplacementPlugin(),
		new HtmlWebpackPlugin({
      template: 'index.html'
    }),
    new ExtractTextPlugin('[name].css')
	],
	devServer: {
    hot: true,
    inline: true,
    stats: 'minimal',
    contentBase: 'app',
    historyApiFallback: true,
    host: '0.0.0.0',
    port: 8001,
    proxy: {
      '/api': {
        target: 'http://0.0.0.0:8080',
        secure: false,
        pathRewrite: {'^/api' : ''}
      }
    }
  }
}
